package com.heima.controller;

import com.heima.pojo.dto.MerchandAddDto;
import com.heima.pojo.dto.MerchandiseDto;
import com.heima.pojo.vo.MerchandisePagingVO;
import com.heima.service.MerchandiseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/sku")
@Slf4j
@RequiredArgsConstructor
public class MerchandiseController {
    @Autowired
    private MerchandiseService merchandiseService;
    //商品查询
    @GetMapping("/search")
    private MerchandisePagingVO search(MerchandiseDto dto){
        log.info("商品查询参数:{}",dto);
        MerchandisePagingVO mpo = merchandiseService.search(dto);
        return mpo;
    }
    //新增商品
    @PostMapping
    private Boolean AddMerchand(@RequestBody MerchandAddDto AddDto){
        log.info("新增商品参数:{}",AddDto);
        return merchandiseService.AddMerchand(AddDto);
    }
    //修改商品
    @PutMapping("/{skuId}")
        private Boolean updateMerchand(@PathVariable Long skuId ,@RequestBody MerchandAddDto updateDto ){
        log.info("修改商品参数:{}",skuId);
        return merchandiseService.updateMerchand(skuId  ,updateDto);
    }
}
